package com.zhangln.mountbuzhou.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author sherry
 * @description
 * @date Create in 2020/4/28
 * @modified By:
 */
@Configuration
public class RabbitMQConfig {

    /**
     * 配置路由模式
     * 消息推送
     */
    @Configuration
    class WebSocketConfig {
        /**
         * 定义自动删除的匿名队列
         *
         * @return
         */
        @Bean
        public Queue webSocketPushAnonymousQueue() {
            return new AnonymousQueue();
        }

        @Bean
        public DirectExchange directExchange() {
            return new DirectExchange(MQConstant.WEB_SOCKET);
        }

        @Bean
        public Binding binding(DirectExchange directExchange, Queue webSocketPushAsnyQueue) {
            return BindingBuilder.bind(webSocketPushAsnyQueue).to(directExchange).with(MQConstant.PUSH);
        }
    }


}
